import mongoose from 'mongoose'
const Schema = mongoose.Schema

const UserSchema = new Schema({
  nickName: String,
  // passWord: String,
  avatarUrl: String,
  province: String,
  city: String,
  country: String,
  gender: String,
  language: String,
  phone: String,
  token: String,
  lastLoginIP: String,
  registerIP: String,
  balance: {
    type: Number,
    default: 0
  },
  lastLoginTime: {
    type: Date,
    default: Date.now()
  },
  registerTime: {
    type: Date,
    default: Date.now()
  },
  lastAcitveTime: {
    type: Date,
    default: Date.now()
  }
})

UserSchema.set('collection', 'Users')

// hidden some field
UserSchema.options.toJSON = {
  virtuals: true,
  versionKey: false,
  transform (doc, ret) {
    ret.id = ret._id
    delete ret._id
  }
}
mongoose.model('Users', UserSchema)
